package com.wrupple.vegetate.server.integration.impl;

import java.util.Collection;

import com.google.inject.Provider;
import com.wrupple.vegetate.server.VegetateServiceLocator;
import com.wrupple.vegetate.server.domain.TokenMapper;
import com.wrupple.vegetate.server.integration.HttpServletRequestHandler;

public abstract class SimpleVegetateServiceLocator extends AbstractVegetateService implements VegetateServiceLocator {
	private TokenMapper moduleMapper;
	
	public SimpleVegetateServiceLocator(TokenMapper moduleMapper) {
		super();
		this.moduleMapper = moduleMapper;
	}
	@Override
	public Collection<VegetateServiceLocator> getChildren() {
		return moduleMapper.getChildren();
	}
	@Override
	protected HttpServletRequestHandler getHandlerForToken(String tokenName) {
		Provider<? extends HttpServletRequestHandler> provider = moduleMapper.get(tokenName);
		return provider==null?null:provider.get();
	}
	
}
